CC = gcc
BIN_DIR = bin

all: server client mkuldl

server: server.c inet_sockets.c log.c | $(BIN_DIR)
	$(CC) $^ -o $(BIN_DIR)/svr

client: client.c log.c | $(BIN_DIR)
	$(CC) $^ -o $(BIN_DIR)/cli

.PHONY: svr, cli, clean, mkuldl
mkuldl:
	@if [ ! -d "download/" ]; then \
		mkdir download; \
	else \
        echo "download folder already exists"; \
	fi

	@if [ ! -d "upload/" ]; then \
        mkdir upload; \
    else \
        echo "upload folder already exists"; \
    fi

svr:
	./$(BIN_DIR)/svr

cli:
	./$(BIN_DIR)/cli

clean:
	rm -f $(BIN_DIR)/svr $(BIN_DIR)/cli

$(BIN_DIR):
	mkdir -p $(BIN_DIR)